<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
	ul{
		margin-left:25;padding:0;
 		list-style:none; 
	}
	.mini-checkboxlist-item{
		padding: 10px;
	}
</style>
</head>
<body>
	<div id="datagrid1" class="mini-datagrid" showPager="false" onlyCheckSelection="true" idField="id" allowCellWrap="true" url="contact_record_view.do" style="width:100%;height:auto;">
		<div property="columns">
			<div type="indexcolumn" width="15"></div>
			<div field="operatorUser" width="50" headerAlign="center" align="center">座席</div>
			<div field="contactTime" width="70" headerAlign="center" align="center" dateFormat="yyyy-MM-dd HH:mm:ss">联系时间</div>
			<div field="contactWay" width="50" headerAlign="center" align="center">联系方式</div>
			<div field="remarks" width="250" headerAlign="center" align="left">备注</div>
		</div>
	</div>
	<fieldset style="border:solid 1px #aaa;padding:3px;">
		<legend >添加联系记录</legend>
		<input id="customer_id" class="mini-hidden" />
		<div id="form1">
	        <table cellspacing="10" cellpadding="0">
		        <tr>
		            <td>联系方式：</td>
		            <td style="width: 100px;">
		            	<input name="contactWay" style="width: 80px;" class="mini-combobox" data="contactType" value="0" required="true"/>
		            </td>
		        	<td>备注：</td>
		        	<td>
		        		<input class="mini-textbox" name="remarks" style="width: 510px;" required="true"/>
		        	</td>
		        	<td>
		        		<sec:authorize url='/contact_record_save.do'>
		        		<a class="mini-button" onclick="onOk" style="width:50px;">添加</a>
		        		</sec:authorize>
		        	</td>
		        </tr>
	    	</table>
		</div>
	</fieldset>
<script type="text/javascript">
	var contactType = [{ id: 1, text: "呼入"}, { id: 0, text: "呼出"}];
	mini.parse();
	
	var grid = mini.get("datagrid1");
	var form1 = new mini.Form("form1");
	var cId = mini.get("customer_id");
	function SetData(data) {
		data = mini.clone(data);
		cId.setValue(data.customerId);
		grid.load({customerId: data.customerId});
	}
	
	function onOk(){
		var o = form1.getData(true); 
	    form1.validate();
	    if (form1.isValid() == false) return;
	    $.ajax({
	        url: "contact_record_save.do?customerId=" + cId.getValue(),
			type: 'post',
			dataType: 'json',
	        data: o,
	        cache: false,
	        success: function (text) {
	            if(text.success) {
	            	form1.clear();
	            	grid.load({customerId: cId.getValue()});
	            }
	        }
	    });
	}
</script>
</body>
</html>